package com.demo.las.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.file.Paths;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String labUploadUri = Paths.get(System.getProperty("user.dir"), "uploads", "lab_reports")
                .toAbsolutePath().toUri().toString();
        registry.addResourceHandler("/lab_reports/**")
                .addResourceLocations(labUploadUri);

        String majorUploadUri = Paths.get(System.getProperty("user.dir"), "uploads", "major_reports")
                .toAbsolutePath().toUri().toString();
        registry.addResourceHandler("/major_reports/**")
                .addResourceLocations(majorUploadUri);
    }
}